import Equip from "../models/equip/equip.model";
import Hero from "../models/hero/hero.model";

/**
 * @Author: 陈瑞鹏
 * @Date:   2022-10-17 15:25:11
 * @Last Modified by:   陈瑞鹏
 * @Last Modified time: 2022-10-17 15:25:56
 */
export default class equip {
  /**
     * 解析武将装备_id  将_id转为装备数据
     * @param roleId 角色ID
     */
  static async analysisHeroEquip_id(roleId: number) {
    let HeroRes: any = await Hero.find({ roleId });
    for (const iterator of HeroRes) {
      for (const key in iterator.equipment) {
        if (iterator.equipment[key] != '' && iterator.equipment[key] != 0) {
          let EquipRes: any = await Equip.findById({ _id: iterator.equipment[key] })
          iterator.equipment[key] = EquipRes;
        }
      }
    }
    return HeroRes
  }
}